<?php

// phpMyRealty 3
//
// File Name: dbbackup.php
// File Location : ./admin/
//
// Copyright (c)2009 phpMyRealty.com
//
// e-mail: support@phpMyRealty.com

// Include configuration file and general functions
define('PMR', 'true');
define('PMRADMIN', 'true');

include ( '.././config.php' );
include ( PATH . '/defaults.php' );

// ----------------------------------------------------------------------
// ADMIN PANEL / CREATE SQL DUMP

// If logged we can start the page output
if (adminAuth($session->fetch('adminlogin'), $session->fetch('adminpassword')))

 {

  $mime_type = ('USER_BROWSER_AGENT' == 'IE' || 'USER_BROWSER_AGENT' == 'OPERA')
  ? 'application/octetstream'
  : 'application/octet-stream';


  $now = gmdate('D, d M Y H:i:s') . ' GMT';
  $filename = $dbi['sql_dbname'] . '-' . printdate(date('y-m-d'));
  $ext = "sql";
  $crlf = define_crlf();

  header('Content-Type: ' . $mime_type);
  header('Expires: ' . $now);

  if ('USER_BROWSER_AGENT' == 'IE') 
   {
    header('Content-Disposition: inline; filename="' . $filename . '.' . $ext . '"');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
   }
  else
   {
    header('Content-Disposition: attachment; filename="' . $filename . '.' . $ext . '"');
    header('Pragma: no-cache');
   }

  mysqlbackup($dbi['sql_dbname'], FALSE, $crlf);

 }

else

 error ('Critical Error' , 'Please, login to access this script.');

?>